		//This will be a mouse cursor function.
		//It will follow the motion of the mouse with a box of _____ color.
		
		//The box's dimensions (cursor_x1,cursor_y1,cursor_x2,cursor_y2) are determined by the 'width' variable.\
		//Also, to make there only be 1 cursor on the screen I will have a process of painting the new cursor
		//and 'removing' the old one by painting it the color of the background.
		
		//This program WILL NOT run on its own. It requires the vga and mouse drivers as well.
		//It is suggested that you make your main or testing file include this one along with the other 2.
		//Written by Kwesi Rutledge.
		
					
cursor			add newx_pos	oldx_pos	mouse_deltax			//Initialize position of the cursor
				add newy_pos	oldy_pos	mouse_deltay
				
				be	enter	first	preset0
		
cursor_check1	be cursor_check2		newx_pos	oldx_pos		//If the mouse hasn't moved don't go through this ordeal.
cursor_check2	be cursor_end			newy_pos	oldy_pos
		
			//--------------------------------------------------------------------------
		
			//Delete old cursor.
			//We will do this by using a loop that will go through the 5x5 area that
			//the cursor was in and replacing it with the old values from the background.
			
			//--------------------------------------------------------------------------
			
			
			sub cursor_x1		oldx_pos	width			//Make the dimensions of the old box.
			sub cursor_y1		oldy_pos	width
		
			add	cursor_x2	oldx_pos	width
			add cursor_y2	oldy_pos	width

			add cursor_x2	cursor_x2 preset1				//MODIFYING cursor_x2 and cursor_y2 increased to help the loops.
			add cursor_y2	cursor_y2 preset1				

			cp orig_x1	cursor_x1							//We must save these values for later use in our loop.

loop_old	cp vga_x1	cursor_x1							//Retrieve the values of background and rewrite them to the
 															//them to the screen.
			cp vga_y1	cursor_y1
			cp vga_x2	cursor_x1
			cp vga_y2	cursor_y1
		
			cp 		vga_write 		preset1
			
			cpfa	vga_color_write	backg_info	cursor_i	//This copy from array will change with each loop to
															//copy every data peice saved in our array.
															
			call 	VGA VGA_return							//Color the old box the color of the background.
			

			add 	cursor_i cursor_i preset1				//Increment i.
		
			add 	cursor_x1	cursor_x1 preset1			//Update the column that we're working on.
			
			blt 	loop_old	cursor_x1 cursor_x2 
			
			cp 		cursor_x1 	orig_x1
			
			add 	cursor_y1 	cursor_y1 preset1			//Update the row as needed.
			
			blt 	loop_old	cursor_y1 cursor_y2
			
			add cursor_x2	cursor_x2 preset1				//MODIFYING cursor_x2 and cursor_y2 back to their original values.
			add cursor_y2	cursor_y2 preset1				
							
			cp cursor_i preset0								//Reset the value of i to 0.
			
			//-------------------------------------------------					
		
			//Record the values of the background where the cursor will be.
			
			//-------------------------------------------------
		
create		sub cursor_x1	newx_pos	width				//Make the dimensions of the new box.
			sub cursor_y1	newy_pos	width	
		
			add	cursor_x2	newx_pos	width
			add cursor_y2	newy_pos	width

			add cursor_x2	cursor_x2 preset1				//MODIFYING cursor_x2 and cursor_y2 to help the loops.
			add cursor_y2	cursor_y2 preset1				
		
			cp orig_x1 cursor_x1							//These values must be saved for later.
			cp orig_y1 cursor_y1 
		
loop_new	cp vga_x1	cursor_x1
			cp vga_y1	cursor_y1
			cp vga_x2	cursor_x1
			cp vga_y2	cursor_y1
		
			cp vga_write preset0
		
			call VGA VGA_return								// Retrieve the values of the background before
															// they are replaced by the cursor.
			
			cpta vga_color_read backg_info cursor_i
			
			add cursor_i cursor_i preset1					//Increment i.
			
			add cursor_x1 cursor_x1 preset1					//Update the column being operated on.
			
			blt loop_new cursor_x1 cursor_x2
			
			cp cursor_x1 orig_x1
			
			add cursor_y1 cursor_y1 preset1					//Update the row being operated on.
			
			blt	loop_new cursor_y1 cursor_y2
		
			sub cursor_x2	cursor_x2 preset1				//MODIFYING cursor_x2 and cursor_y2 back to their original values.
			sub cursor_y2	cursor_y2 preset1				
		
			cp cursor_i	preset0
		
			//--------------------------------------------------------
		
			//Create new cursor.
			
			//--------------------------------------------------------
			
			cp vga_x1	orig_x1						//Finally draw the box where the cursor is.
			cp vga_y1	orig_y1
			cp vga_x2	cursor_x2
			cp vga_y2	cursor_y2
		
			cp vga_write 		preset1
			cp vga_color_write 	width
			
			call VGA VGA_return
				
			//Swap new value into old.
		
			cp oldx_pos	newx_pos
			cp oldy_pos	newy_pos
		
		
		
cursor_end	ret cursor_return

		
enter		add first first preset1
			be create preset1 preset1		

		
		
cursor_return	.data 0

cursor_x1		.data 0
cursor_y1		.data 0
cursor_x2		.data 0
cursor_y2		.data 0

deltax			.data 0
deltay			.data 0

oldx_pos		.data 320			//These are the coordinates of the old cursor.
oldy_pos		.data 240

newx_pos		.data 0				//These are the coordinates of the new cursor.
newy_pos		.data 0

orig_x1			.data 0				//These hold the values of cursor_x1 and cursor_y1 of the cursor box
orig_y1			.data 0				//while the retrieval/display loops occur.

width			.data 2
six				.data 6

first			.data 0
cursor_i		.data 0

backg_info		.data 0
				.data 0
				.data 0
				.data 0
				.data 0
				
				.data 0
				.data 0
				.data 0
				.data 0
				.data 0
				
				.data 0
				.data 0
				.data 0
				.data 0
				.data 0
				
				.data 0
				.data 0
				.data 0
				.data 0
				.data 0
				
				.data 0
				.data 0
				.data 0
				.data 0
				.data 0				//KEEP THIS DATA CONTINUOUS THIS IS AN ARRAY WHERE WE WILL STORE
									//AND RETRIEVE INFORMATION FOR THE MOUSE TO DELETE ITS OLD PLACE.
				

